const vm = new Vue({
    el: '#app',
    delimiters: ['[[', ']]'],
    data: {
        username: getCookie('username'),
        category_id: category_id,
        hot_skus: [],
        cart_total_count: 0,
        carts: [],
    },

    mounted() {
        // 获取热销商品数据
        this.get_hot_skus();
        // 获取简单购物车数据
        // this.get_carts();
    },

    methods: {
        // 获取热销商品数据
        get_hot_skus() {
            if (this.category_id) {
                let url = '/hot/' + this.category_id + '/';
                axios.get(url, {
                    responseType: 'json'
                })
                    .then(response => {
                        this.hot_skus = response.data.hot_skus;
                        // for (let i = 0; i < this.hot_skus.length; i++) {
                        //     this.hot_skus[i].url = '/detail/' + this.hot_skus[i].id + '/';
                        // }
                    })
                    .catch(error => {
                        console.log(error.response);
                    })
            }
        },
    }

});
